package fem2.pre_and_post;

import org.junit.Test;

import fem2.Face;
import fem2.Mesh;
import fem2.MeshUtilities;
import fem2.Node;
import fem2.mesh_and_topology.LineSpatialCriteria;
import fem2.mesh_and_topology.SpatialCriteria;

public class MeshUtilitiesTest {

	@Test
	public void testJoinMesh() {
		Node n1 = new Node(0, 0);
		Node n2 = new Node(1, 0);
		Node n3 = new Node(2, 0);
		Node n4 = new Node(0, 1);
		Node n5 = new Node(1, 1);
		Node n6 = new Node(2, 1);
		Face f1 = new Face(n1, n2, n5, n4);
		Face f2 = new Face(n2, n3, n6, n5);

		Mesh mesh1 = new Mesh();
		mesh1.addNode(n1);
		mesh1.addNode(n2);
		mesh1.addNode(n5);
		mesh1.addNode(n4);
		mesh1.addFace(f1);
		mesh1.Print();

		Mesh mesh2 = new Mesh();
		mesh2.addNode(n2);
		mesh2.addNode(n3);
		mesh2.addNode(n6);
		mesh2.addNode(n5);
		mesh2.addFace(f2);
		mesh2.Print();

		SpatialCriteria c = new LineSpatialCriteria(1, 0, 0, 1);

		mesh1 = MeshUtilities.joinMesh(mesh1, mesh2, c);
		mesh1.Print();
	}
}
